# @author 菠萝吹雪
# @date 2024/4/19 16:47
import requests
from bs4 import BeautifulSoup

list = []
header = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 "
                  "Safari/537.36"}
for start_num in range(0, 250, 25):
    text = requests.get(f"https://movie.douban.com/top250?start={start_num}", headers=header).text
    soup = BeautifulSoup(text, "html.parser")
    all_title = soup.findAll("span", attrs={"class": "title"})
    for title in all_title:
        text = title.text
        if "/" not in text:
            # print(text)
            list.append(text)
print("一共有" + str(len(list)) + "部电影")
for i in range(0, len(list)):
    print(i + 1, list[i])

